<template>
    <div class="">

        <p class="pt15 fbold fs18 c38 pl15 pr27 bgfff">{{title}}</p>

        <p class="pl16 bgfff">
            <span class="fs12 ca8 mr10">{{time}}</span>
            <span class="cdeepblue fs12" @click="del">删除</span>
        </p>

        <div v-html="details">

        </div>
      <div class="textc disflex w60 h60 bradius50p bgblue disinblock goToUserCenter" @click="page_turn('mine')">
        <img src="https://one-stand.oss-cn-shanghai.aliyuncs.com/yimai_photos/user/user_add.png" alt="" class="w30 h30 mt15">
      </div>
    </div>
</template>

<script>
    import WXAJAX from '@/utils/request'
    import util from '@/utils/index'

    export default {
        name: '',
        components: {},
        data() {
            return{
                dynamicId : 0,
                title:'',
                details:'',
                time:''
            }
        },
        mounted() {
            wx.setNavigationBarTitle({
                title: "动态详情"
            });
            this.dynamicId = this.$root.$mp.query.id;
            this.getInits() ;
        },
        methods: {
          page_turn(url){
            wx.reLaunch({url:'../'+url+'/main'});
          } ,
            getInits(){
                wx.showLoading() ;

                WXAJAX.POST({
                    dynamicId  : this.dynamicId  ,
                }, '', '/company/getDynamicInfo').then((data) => {

                    wx.hideLoading();
                    if(data){
                        data = data[0] ;
                        this.title = data.title ;
                        this.time = util.getdate(data.createTime , 'dateTime') ;
                        this.details = data.details ;
                    }

                }).catch((err) => {
                    console.log(err);
                    wx.hideLoading();
                });
            },
            del(){
                wx.showLoading() ;

                WXAJAX.POST({
                    dynamicId  : this.dynamicId  ,
                }, '', '/company/delDynamicInfo').then((data) => {

                    wx.hideLoading();
                    wx.showToast({
                        title: '成功！',
                        icon : 'success'
                    });
                    setTimeout(function () {
                        wx.navigateBack() ;
                    },600);
                }).catch((err) => {
                    console.log(err);
                    wx.hideLoading();
                });
            }
        }
    }
</script>

<style>
  .goToUserCenter{
    position: fixed;
    right: 10px;
    bottom: 51px;
    z-index: 99;
    box-sizing: border-box;
    text-align: center;
  }
</style>
